﻿<%@ Page Language="C#" %>
<%@ Import Namespace="System.Data.OleDb" %>
<%@ import Namespace="System.Data" %>
<%
    OleDbConnection conn = null;
    int[] breakpoints = { 5, 45, 770, 13740 };
    int l = breakpoints.Length + 1;
    string[] labels = new string[l];
    for (int n = 0; n < l; n++) {
        if (n == 0)
        {
            labels[n] = "0" + " - " + breakpoints[n];
            continue;
        }
        if (n == l - 1) {
            labels[n] = breakpoints[n-1] + "及以上";
            continue;
        }
        labels[n] = breakpoints[n-1] + " - " + breakpoints[n];
    }
    string querystem = " select count(*) from jz where y07total + y08total <> 0 and y07total + y08total <> '' ";

    try
    {
        conn = DBOp.DbConn;
%>
<chart caption='建筑年单位面积耗电量统计' subcaption='(2007年及2008年  单位：千瓦时/平方米)' legendPosition='right' labelDisplay='ROTATE' slantLabels='1'  xAxisName='单位面积用电量' yAxisName='频度' formatNumberScale='0' baseFontSize='12' baseFontFamily='宋体' numberPrefix='' showValues='0' alternateHGridColor='FCB541' alternateHGridAlpha='20' divLineColor='FCB541' divLineAlpha='50' canvasBorderColor='666666' baseFontColor='666666' lineColor='FCB541'>
<%

    OleDbDataReader reader;        
    for (int n = 0; n < l; n++) {
        OleDbCommand comm = conn.CreateCommand();
        if (n == 0)
        {
            comm.CommandText = querystem + " and FIX((y07total + y08total)/2  / 建筑面积) >=0 and FIX((y07total + y08total)/2  / 建筑面积) < " + breakpoints[n];
            reader = comm.ExecuteReader();
            if (reader.Read()) {
%><set label='<%=labels[n] %>' value='<%=reader.GetValue(0).ToString() %>' /><%
            }
            continue;
        }
        if (n == l - 1)
        {
            comm.CommandText = querystem + " and FIX((y07total + y08total)/2  / 建筑面积) >= "+ breakpoints[n-1];
            reader = comm.ExecuteReader();
            if (reader.Read()) {
%><set label='<%=labels[n] %>' value='<%=reader.GetValue(0).ToString() %>' /><%
            }
            continue;
        }         
        comm.CommandText = querystem + " and FIX((y07total + y08total)/2  / 建筑面积) >="+breakpoints[n-1]+" and FIX((y07total + y08total)/2  / 建筑面积) < "+breakpoints[n];
        reader = comm.ExecuteReader();
        if (reader.Read()) {
%><set label='<%=labels[n] %>' value='<%=reader.GetValue(0).ToString() %>' /><%
            }
    }
                
                %>

	<styles>
		<definition>
			<style name='Anim1' type='animation' param='_xscale' start='0' duration='1' />
			<style name='Anim2' type='animation' param='_alpha' start='0' duration='0.6' />
			<style name='DataShadow' type='Shadow' alpha='40'/>
		</definition>
		<application>
			<apply toObject='DIVLINES' styles='Anim1' />
			<apply toObject='HGRID' styles='Anim2' />
			<apply toObject='DATALABELS' styles='DataShadow,Anim2' />
	</application>	
	</styles>

</chart>                 
              
                
                <%
            
        }
            catch(Exception ex){}
                    finally{
                        if (conn != null)
                            conn.Close();
        }
                        %>
